module manager {

    export class DisplayManager {

        public static STAGE_WIDTH: number = 0;
        public static STAGE_HEIGHT: number = 0;
        public static SCREEN_SCALE: number = 1;

        public static GAME_WIDTH: number = 0;
        public static GAME_HEIGHT: number = 0;
        public static GAME_HEIGHT2: number = 0;

        public static remove(obj: egret.DisplayObject): boolean {
            if (obj != null && obj.parent != null) {
                obj.parent.removeChild(obj);
                return true;
            }
            return false;
        }

        public static init(stage: egret.Stage): void {
            DisplayManager.STAGE_WIDTH = stage.stageWidth;
            DisplayManager.STAGE_HEIGHT = stage.stageHeight;
            DisplayManager.SCREEN_SCALE = 750 / 1168;
            DisplayManager.GAME_WIDTH = stage.stageWidth;
            DisplayManager.GAME_HEIGHT = stage.stageHeight;
            DisplayManager.GAME_HEIGHT2 = stage.stageHeight;
        }

        public static setRealBannerAdSize(width: number, height: number, type: string): void {
            let info = wx.getSystemInfoSync();
            if (type == "wxa"){
                let ad_h = (height / info.screenHeight) * DisplayManager.STAGE_HEIGHT;
                DisplayManager.GAME_HEIGHT2 = DisplayManager.STAGE_HEIGHT - ad_h;
            } else {
                DisplayManager.GAME_HEIGHT2 = DisplayManager.STAGE_HEIGHT - height;
            }
            GameManager.getInstance().dispatchEvent(new egret.Event(GameManager.GAME_SIZE_CHANGED));
        }

        public static removeAllChildren(container: egret.DisplayObjectContainer): void {
            while (container.numChildren > 0) {
                container.removeChildAt(0);
            }
        }
    }

}